

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>mindspore.ops.HyperMap &mdash; MindSpore master documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="mindspore.ops.jvp" href="mindspore.ops.jvp.html" />
    <link rel="prev" title="mindspore.ops.GradOperation" href="mindspore.ops.GradOperation.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> MindSpore
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">MindSpore Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../mindspore.html">mindspore</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.common.initializer.html">mindspore.common.initializer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.communication.html">mindspore.communication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.compression.html">mindspore.compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.context.html">mindspore.context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.html">mindspore.dataset</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.audio.html">mindspore.dataset.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.config.html">mindspore.dataset.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.text.html">mindspore.dataset.text</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.transforms.html">mindspore.dataset.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.vision.html">mindspore.dataset.vision</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.mindrecord.html">mindspore.mindrecord</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.html">mindspore.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.probability.html">mindspore.nn.probability</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.transformer.html">mindspore.nn.transformer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.numpy.html">mindspore.numpy</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../mindspore.ops.html">mindspore.ops</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../mindspore.ops.html#operations">operations</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../mindspore.ops.html#functional">functional</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.batch_dot.html">mindspore.ops.batch_dot</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.clip_by_global_norm.html">mindspore.ops.clip_by_global_norm</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.clip_by_value.html">mindspore.ops.clip_by_value</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.core.html">mindspore.ops.core</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.count_nonzero.html">mindspore.ops.count_nonzero</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.cummin.html">mindspore.ops.cummin</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.dot.html">mindspore.ops.dot</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.gamma.html">mindspore.ops.gamma</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.grad.html">mindspore.ops.grad</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.GradOperation.html">mindspore.ops.GradOperation</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">mindspore.ops.HyperMap</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.jvp.html">mindspore.ops.jvp</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.laplace.html">mindspore.ops.laplace</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.Map.html">mindspore.ops.Map</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.matmul.html">mindspore.ops.matmul</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.multinomial.html">mindspore.ops.multinomial</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.MultitypeFuncGraph.html">mindspore.ops.MultitypeFuncGraph</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.narrow.html">mindspore.ops.narrow</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.normal.html">mindspore.ops.normal</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.poisson.html">mindspore.ops.poisson</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.repeat_elements.html">mindspore.ops.repeat_elements</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.select.html">mindspore.ops.select</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.sequence_mask.html">mindspore.ops.sequence_mask</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.tensor_dot.html">mindspore.ops.tensor_dot</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.uniform.html">mindspore.ops.uniform</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ops.vjp.html">mindspore.ops.vjp</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.ops.html#id11">原语</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.ops.html#id12">函数实现注册</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.ops.html#id13">算子信息注册</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.html">mindspore.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.nn.html">mindspore.parallel.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.profiler.html">mindspore.profiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.scipy.html">mindspore.scipy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.train.html">mindspore.train</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.boost.html">mindspore.boost</a></li>
</ul>
<p class="caption"><span class="caption-text">MindSpore C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://www.mindspore.cn/lite/api/zh-CN/master/api_cpp/mindspore.html">MindSpore Lite↗</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">MindSpore</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../mindspore.ops.html">mindspore.ops</a> &raquo;</li>
        
      <li>mindspore.ops.HyperMap</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/api_python/ops/mindspore.ops.HyperMap.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="mindspore-ops-hypermap">
<h1>mindspore.ops.HyperMap<a class="headerlink" href="#mindspore-ops-hypermap" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="mindspore.ops.HyperMap">
<em class="property">class </em><code class="sig-prename descclassname">mindspore.ops.</code><code class="sig-name descname">HyperMap</code><span class="sig-paren">(</span><em class="sig-param">ops=None</em>, <em class="sig-param">reverse=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mindspore/ops/composite/base.html#HyperMap"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mindspore.ops.HyperMap" title="Permalink to this definition">¶</a></dt>
<dd><p>Hypermap will apply the set operation to input sequences.</p>
<p>Apply the operations to every element of the sequence or nested sequence. Different
from <cite>Map</cite>, the <cite>HyperMap</cite> supports to apply on nested structure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ops</strong> (<em>Union</em><em>[</em><a class="reference internal" href="mindspore.ops.MultitypeFuncGraph.html#mindspore.ops.MultitypeFuncGraph" title="mindspore.ops.MultitypeFuncGraph"><em>MultitypeFuncGraph</em></a><em>, </em><a class="reference external" href="https://docs.python.org/library/constants.html#None" title="(in Python v3.8)"><em>None</em></a><em>]</em>) – <cite>ops</cite> is the operation to apply. If <cite>ops</cite> is <cite>None</cite>,
the operations should be put in the first input of the instance. Default is None.</p></li>
<li><p><strong>reverse</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a>) – The optimizer needs to be inverted in some scenarios to improve parallel performance,
general users please ignore. <cite>reverse</cite> is the flag to decide if apply the operation reversely.
Only supported in graph mode. Default is False.</p></li>
</ul>
</dd>
</dl>
<dl>
<dt>Inputs:</dt><dd><ul>
<li><p><strong>args</strong> (Tuple[sequence]) - If <cite>ops</cite> is not <cite>None</cite>, all the inputs should be sequences with the same length.
And each row of the sequences will be the inputs of the operation.</p>
<p>If <cite>ops</cite> is <cite>None</cite>, the first input is the operation, and the others are inputs.</p>
</li>
</ul>
</dd>
<dt>Outputs:</dt><dd><p>Sequence or nested sequence, the sequence of output after applying the function.
e.g. <cite>operation(args[0][i], args[1][i])</cite>.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><ul class="simple">
<li><p><a class="reference external" href="https://docs.python.org/library/exceptions.html#TypeError" title="(in Python v3.8)"><strong>TypeError</strong></a> – If <cite>ops</cite> is neither MultitypeFuncGraph nor None.</p></li>
<li><p><a class="reference external" href="https://docs.python.org/library/exceptions.html#TypeError" title="(in Python v3.8)"><strong>TypeError</strong></a> – If <cite>args</cite> is not a Tuple.</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Supported Platforms:</dt><dd><p><code class="docutils literal notranslate"><span class="pre">Ascend</span></code> <code class="docutils literal notranslate"><span class="pre">GPU</span></code> <code class="docutils literal notranslate"><span class="pre">CPU</span></code></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore</span> <span class="kn">import</span> <span class="n">Tensor</span><span class="p">,</span> <span class="n">ops</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore.ops.composite.base</span> <span class="kn">import</span> <span class="n">MultitypeFuncGraph</span><span class="p">,</span> <span class="n">HyperMap</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore</span> <span class="kn">import</span> <span class="n">dtype</span> <span class="k">as</span> <span class="n">mstype</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">nest_tensor_list</span> <span class="o">=</span> <span class="p">((</span><span class="n">Tensor</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">mstype</span><span class="o">.</span><span class="n">float32</span><span class="p">),</span> <span class="n">Tensor</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">mstype</span><span class="o">.</span><span class="n">float32</span><span class="p">)),</span>
<span class="gp">... </span>                    <span class="p">(</span><span class="n">Tensor</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">mstype</span><span class="o">.</span><span class="n">float32</span><span class="p">),</span> <span class="n">Tensor</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="n">mstype</span><span class="o">.</span><span class="n">float32</span><span class="p">)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># square all the tensor in the nested list</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">square</span> <span class="o">=</span> <span class="n">MultitypeFuncGraph</span><span class="p">(</span><span class="s1">&#39;square&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nd">@square</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="s2">&quot;Tensor&quot;</span><span class="p">)</span>
<span class="gp">... </span><span class="k">def</span> <span class="nf">square_tensor</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">return</span> <span class="n">ops</span><span class="o">.</span><span class="n">square</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">common_map</span> <span class="o">=</span> <span class="n">HyperMap</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">output</span> <span class="o">=</span> <span class="n">common_map</span><span class="p">(</span><span class="n">square</span><span class="p">,</span> <span class="n">nest_tensor_list</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>
<span class="go">((Tensor(shape=[], dtype=Float32, value= 1), Tensor(shape=[], dtype=Float32, value= 4)),</span>
<span class="go">(Tensor(shape=[], dtype=Float32, value= 9), Tensor(shape=[], dtype=Float32, value= 16)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">square_map</span> <span class="o">=</span> <span class="n">HyperMap</span><span class="p">(</span><span class="n">square</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">output</span> <span class="o">=</span> <span class="n">square_map</span><span class="p">(</span><span class="n">nest_tensor_list</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>
<span class="go">((Tensor(shape=[], dtype=Float32, value= 1), Tensor(shape=[], dtype=Float32, value= 4)),</span>
<span class="go">(Tensor(shape=[], dtype=Float32, value= 9), Tensor(shape=[], dtype=Float32, value= 16)))</span>
</pre></div>
</div>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="mindspore.ops.jvp.html" class="btn btn-neutral float-right" title="mindspore.ops.jvp" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="mindspore.ops.GradOperation.html" class="btn btn-neutral float-left" title="mindspore.ops.GradOperation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2021, MindSpore.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>